<template>
	<view class="content">
		<view class="header-box">
			<view class="banlance-price">
				<view style="font-size: 24rpx;">直推拼团奖励</view>
				<view class="x-bc" style="margin-top: 39rpx;">
					<view>{{userInfo.sum_team}}</view>
					<!-- <view @click="junit('/pages/prefile/my-diamond/transfer/transfer')" class="raduis-btn">转让</view> -->
				</view>
			</view>
			<!-- <view class="group-box-row">
				<view class="blance-group-item">
					<view class="title">今日补贴</view>
					<view class="price">￥{{diamond.toady_subsidy}}</view>
				</view>
				<view class="line"></view>
				<view class="blance-group-item">
					<view class="title">昨日补贴</view>
					<view class="price">￥{{diamond.yesterday}}</view>
				</view>
				<view class="line"></view>
				<view class="blance-group-item">
					<view class="title">累计补贴</view>
					<view class="price">￥{{diamond.total}}</view>
				</view>
			</view> -->
			<!-- <view class="tixian" @click="junit('/pages/prefile/my-balance/tixian/tixian')">立即提现</view> -->
		</view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
			<view class="balance-box">
				<!-- <view class="balance-tips">
					<view class="balance-name">红包明细</view>
					<view class="loding-box" @click="junit('/pages/prefile/my-diamond/diamond-list/diamond-list')">
						<!-- <text class="loding-title">更多</text> 
						<image src="../../../static/images/prefile/more.png"></image>
					</view>
				</view> -->
				<view class="balance-list">
					<view class="balance-item" v-for="(item, index) in diamondList" :key="index">
						<view class="balance-left">
							<view class="balance-status">{{item.remark}}</view>
							<view class="balance-time">{{item.created_at}}</view>
						</view>
						<view class="balance-right">
							{{item.change_money}}
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import {
		mapState,
	} from 'vuex';
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				diamond: 0,
				diamondList: [],
				page: 1
			};
		},
		computed: {
			...mapState(['userInfo'])
		},
		onLoad() {
			this.getUserDiamond();
			this.getUserDiamondList();
		},
		methods: {
			junit(url) {
				uni.navigateTo({
					url: url
				})
			},
			// 获取红包
			async getUserDiamond() {
				let apiUrl = `/addons/yun_shop/api.php?route=plugin.love.Frontend.Controllers.page.index`
				let params = { mid: 140 }
				this.$api.get(apiUrl, params, {paramsType: 2}).then(res => {
					console.log(res,111);
					this.diamond = res.data
				})
			},
			// 获取收入支出明细
			async getUserDiamondList() {
				let apiUrl = `/addons/yun_shop/api.php?route=member.member.teamlist`
				let params = {
					page: this.page,
					uuid: 0,
					mid: this.userInfo.uid,
					shop_id: 0,
					service_type: 0
				}
				this.$api.get(apiUrl, params).then(res => {
					console.log(res,222);
					this.diamondList = res.data.data;
				})
			},
			// 下拉刷新列表
			downCallback() {
				this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
			},
			/*上拉加载的回调*/
			async upCallback(page) {
				this.page = page.num;
				let apiUrl = `/addons/yun_shop/api.php?route=member.member.teamlist`
				let params = {
					page: this.page,
					uuid: 0,
					mid: this.userInfo.uid,
					shop_id: 0,
					service_type: 0
				}
				this.$api.get(apiUrl, params).then(res => {
					let len = res.data.data.length
					let total = res.data.total
					if (page.num == 1) {
						this.diamondList = []; //如果是第一页需手动置空列表
					}
					this.diamondList = this.diamondList.concat(res.data.data); //追加新数据
					this.mescroll.endBySize(len, total);
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	@import './my-extents-group.scss';
</style>
